import 'package:boss/color_constant.dart';
import 'package:boss/textStyle/text_style.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';

class TitleSwitch extends StatelessWidget {
  final dynamic title;
  final bool value;
  final Color activeColor;
  final ValueChanged<bool> onChanged;

  const TitleSwitch({
    Key key,
    @required this.title,
    @required this.value,
    this.activeColor,
    this.onChanged,
  })  : assert(title is String || title is Widget),
        super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 90.w,
      decoration: BoxDecoration(
        border: Border(
          bottom: BorderSide(
            color: ColorConstant.e6e6,
            width: 1.px,
          ),
        ),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: <Widget>[
          title is String
              ? Text(
                  title,
                  style: TextStyleConstant().normal_1_28,
                )
              : title,
          CupertinoSwitch(
            value: value,
            onChanged: onChanged,
            activeColor: activeColor ?? ColorConstant.ff5770f6,
          ),
        ],
      ),
    );
  }
}
